import java.util.ArrayList;
import java.util.Scanner;

// 学生类
class Student {
    private String name;
    private int age;
    private String studentId;

    // 构造函数
    public Student(String name, int age, String studentId) {
        this.name = name;
        this.age = age;
        this.studentId = studentId;
    }

    // Getter 和 Setter 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    // 重写toString方法，方便打印学生信息
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", studentId='" + studentId + '\'' +
                '}';
    }
}

// 学生管理系统类
public class StudentManagementSystem {
    private ArrayList<Student> students = new ArrayList<>();
    private Scanner scanner = new Scanner(System.in);

    // 添加学生
    public void addStudent() {
        System.out.print("请输入学生姓名: ");
        String name = scanner.nextLine();
        System.out.print("请输入学生年龄: ");
        int age = scanner.nextInt();
        scanner.nextLine(); // 清除缓冲区
        System.out.print("请输入学生学号: ");
        String studentId = scanner.nextLine();

        Student student = new Student(name, age, studentId);
        students.add(student);
        System.out.println("学生添加成功！");
    }

    // 显示所有学生
    public void displayStudents() {
        if (students.isEmpty()) {
            System.out.println("当前没有学生信息。");
        } else {
            System.out.println("学生列表：");
            for (Student student : students) {
                System.out.println(student);
            }
        }
    }

    // 主菜单
    public void showMenu() {
        while (true) {
            System.out.println("\n===== 学生管理系统 =====");
            System.out.println("1. 添加学生");
            System.out.println("2. 显示所有学生");
            System.out.println("3. 退出");
            System.out.print("请选择操作: ");
            int choice = scanner.nextInt();
            scanner.nextLine(); // 清除缓冲区

            switch (choice) {
                case 1:
                    addStudent();
                    break;
                case 2:
                    displayStudents();
                    break;
                case 3:
                    System.out.println("退出系统。");
                    return;
                default:
                    System.out.println("无效的选择，请重新输入！");
            }
        }
    }

    // 主方法
    public static void main(String[] args) {
        StudentManagementSystem system = new StudentManagementSystem();
        system.showMenu();
    }
}